<template>
  <div class="main-container"
       v-for="(item0, index0) in circleItems"
       :key="index0"
       :style="{
        'background-image': `url(${backgrounds[index0 % backgrounds.length]})`,
      }"
       :class="{ active: showIndex === index0 }"
  >
    <div class="myFilter"></div>
    <div class="circle-content">
      <div
          v-for="(item, index) in circleItems"
          :key="index"
          class="circle-item"
          :class="{ active: showIndex === index }"
          :style="{
          'box-shadow':showIndex === index ? `0 0 0 4px white, 0 0 0 8px ${colors[index % colors.length]}, 0 15px 35px rgba(0, 0, 0, 0.2)` : '0 8px 25px rgba(0, 0, 0, 0.1)',
          'transform': `rotate(${index * anglePerItem}deg) translate(${radius}px) rotate(-${index * anglePerItem}deg)`
        }"
          @click="setIndex(index)"
      >
        <div class="item-icon" :style="{'background':colors[index % colors.length]}">
          <i>
            <img :src="icons[index % icons.length]" alt="favicon" style="width: 20px; margin-top: 6px">
          </i>
        </div>
        <div class="item-label">{{ item }}</div>
      </div>
    </div>

    <div class="content-wrapper">
      <div
          class="text-content"
          v-for="(item, index) in textContent"
          :key="index"
          :class="{ active: showIndex === index }"
      >
        <div class="content-card">
          <div class="card-header" :style="{ background: colors[index % colors.length] }">
            <h2 class="title">{{ item.title }}</h2>
            <div class="card-icon">
              <i :class="icons[index % icons.length]"></i>
            </div>
          </div>

          <div class="card-body">
            <p class="content-text">{{ item.content }}</p>

            <div class="items-container">
              <div
                  v-for="(subItem, subIndex) in item.items"
                  :key="subIndex"
                  class="item-card"
              >
                <div class="item-text">{{ subItem }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed } from 'vue'

const showIndex = ref(0)
const isChose = ref(true)

const setIndex = (index) => {
  showIndex.value = index
}

// 圆形布局参数
const itemCount = 5
const anglePerItem = computed(() => 360 / itemCount)
const radius = 180 // 圆形半径

// 颜色方案
const colors = ref([
  '#4361ee', // 蓝色
  '#3a0ca3', // 深蓝
  '#7209b7', // 紫色
  '#f72585', // 粉色
  '#4cc9f0'  // 青色
])

//图标
import icon1 from "@/assets/homeContent/zhinengjiance.png"
import icon2 from "@/assets/homeContent/zhinengshibie.png"
import icon3 from "@/assets/homeContent/shujuguanli.png"
import icon4 from "@/assets/homeContent/shujufenxi.png"
import icon5 from "@/assets/homeContent/keshihua.png"

//背景
import bg1 from "@/assets/introductionBackground/zhinnegshibie.jpg"
import bg2 from "@/assets/introductionBackground/AIzhinengjiance.jpg"
import bg3 from "@/assets/introductionBackground/shujuguanli.jpg"
import bg4 from "@/assets/introductionBackground/shujufenxi.jpg"
import bg5 from "@/assets/introductionBackground/keshihuashuju.jpg"

// 图标方案
const icons = ref([
  icon1,
  icon2,
  icon3,
  icon4,
  icon5
])

const backgrounds = ref([
    bg1,
    bg2,
    bg3,
    bg4,
    bg5
])

const circleItems = ref([
  "智能监测", "智能识鸟", "数据管理", "数据分析", "可视化"
])

const textContent = ref([
  {
    title: "智能鸟类检测",
    content: "基于深度学习算法，系统能够准确检测各种环境下的鸟类活动。",
    items: ["复杂背景中的鸟类识别", "多目标跟踪与计数统计", "鸟类行为模式分析", "24小时不间断监测"]
  },
  {
    title: "智能识鸟与AI问答",
    content: "上传鸟类图片，鸟类声音即可获得专业识别结果和生态信息。",
    items: ["图片、声音识别鸟类种类", "保护等级与分布信息", "AI鸟类知识问答", "鸟类特征与习性介绍"]
  },
  {
    title: "数据管理",
    content: "系统提供全面的数据管理功能。",
    items: ["监测数据长期存储", "鸟类出现频率统计", "设备运行状态监控", "鸟类种类统计"]
  },
  {
    title: "数据分析",
    content: "系统提供全面的数据分析功能",
    items: ["监测数据分析", "文章词条分析", "声音数据分析", "历史数据分析"]
  },
  {
    title: "数据可视化",
    content: "直观展示监测数据和分析结果。",
    items: ["鸟类检测数据图表展示", "监测点分布可视化", "历史数据趋势图", "设备状态可视化监控"]
  }
])
</script>

<style scoped>
.main-container {
  width: 90%;
  max-width: 1200px;
  height: 600px;
  margin-top:10px;
  margin-left:40px;
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-radius: 25px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  opacity: 0;
  background-size: cover;
}
.main-container.active {
  opacity: 1;
}
.myFilter{
  position: absolute;
  width: 100%;
  max-width: 1200px;
  height: 600px;
  z-index: 1; /* 确保内容在磨砂层之上 */
  border: 1px solid red;
}

.myFilter::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(1px);
  z-index: -1;
}

.circle-content {
  position: relative;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.circle-item {
  position: absolute;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.circle-item:hover {
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.circle-item.active {
  transform: scale(1.15) rotate(0deg) !important;
  z-index: 20;
}

.item-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.item-label {
  font-size: 1rem;
  font-weight: 600;
  color: #2c3e50;
  text-align: center;
}

.content-wrapper {
  width: 600px;
  height: 400px;
  position: relative;
  margin-left: 50px;
}

.text-content {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 1s ease-in-out;
  z-index: 100;
}

.text-content.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.content-card {
  width: 100%;
  height: 100%;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.card-header {
  height: 120px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  color: white;
}

.title {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.card-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
}

.card-body {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
}

.content-text {
  font-size: 1.1rem;
  line-height: 1.7;
  color: #555;
  margin-bottom: 30px;
}

.items-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.item-card {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.item-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.item-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 15px;
}


.item-text {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
}


</style>